#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 3010;
const int mod = 1e9+7;

int nxt[MAXN],n,m,s[MAXN],o,a[MAXN];
char S[MAXN];
ll f[2][MAXN];

void add(ll &x,ll y){x = (x+y) % mod;}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in;
	scanf("%s",S+1);
	for(int i = 1;i <= n;i++) a[i] = S[i] ^ 48;
	for(int i = 1;i <= n+1;i++) s[i] = s[i-1] + a[i];
	for(int i = 1;i <= n+1;i++) nxt[i] = i;
	for(int i = 1;i <= m;i++){
		int l = in,r = in;
		nxt[l] = max(nxt[l],r);
	}
	for(int i = 1;i <= n;i++) nxt[i] = max(nxt[i],nxt[i-1]);
	o = 1; f[o][s[nxt[1]]] = 1;
	for(int i = 1;i <= n;i++,o^=1){
		memset(f[o^1],0,sizeof(f[o^1]));
		int l = nxt[i]+1,r = nxt[i+1];
		for(int j = 0;j <= n;j++){
			if(f[o][j]){
				if(j) add(f[o^1][j-1+s[r]-s[l-1]],f[o][j]);
				if(nxt[i]-i+1>j) add(f[o^1][j+s[r]-s[l-1]],f[o][j]);
			}
		}
	}
	printf("%lld\n",f[o][0]);
	return 0;
}

